home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-15 | 5.4 KB | 203 lines | [TEXT/CWIE] |
- // ===========================================================================
- // GraphTestApp.cp Derived heavily from the Dashboard Starter
- // ===========================================================================
- //
-
- #include "GraphTestApp.h"
-
- #include <LApplication.h>
- #include <LGrowZone.h>
- #include <LWindow.h>
- #include <UDrawingState.h>
- #include <UMemoryMgr.h>
- #include <URegistrar.h>
-
- #include "ColumnGraphWindow.h"
- #include "BarGraphWindow.h"
- #include "StackedBarGraphWindow.h"
-
- #ifdef OOF_SmartHeap
- #include "smrtheap.hpp"
- #endif
-
- // ===========================================================================
- // • Main Program
- // ===========================================================================
-
- void main()
- {
- // Set Debugging options
- SetDebugThrow_(debugAction_Alert);
- SetDebugSignal_(debugAction_Alert);
-
- InitializeHeap(3); // Initialize Memory Manager
- // Parameter is number of Master Pointer
- // blocks to allocate
-
- // Initialize standard Toolbox managers
- UQDGlobals::InitializeToolbox(&qd);
-
- new LGrowZone(20000); // Install a GrowZone function to catch
- // low memory situations.
- // Parameter is size of reserve memory
- // block to allocated. The first time
- // the GrowZone function is called,
- // there will be at least this much
- // memory left (so you'll have enough
- // memory to alert the user or finish
- // what you are doing).
-
- GraphTestApp theApp; // Create instance of your Application
- theApp.Run(); // class and run it
- }
-
-
- // ===========================================================================
- // • GraphTestApp Class
- // ===========================================================================
-
- // ---------------------------------------------------------------------------
- // • GraphTestApp
- // ---------------------------------------------------------------------------
- // Constructor
-
- GraphTestApp::GraphTestApp()
- {
- //theDB.useSeparateFiles();
-
- // Open OOFile DBs
- if (dbConnect::fileExists("Databases")) {
- theDB.openConnection("Databases");
- }
- else {
- theDB.newConnection("Databases");
- Students.AddTestData();
- Temperatures.AddTestData();
- }
- Students.setSortOrder(dbSorter() << Students.Name << Students.Subject);
-
- dbView Sview(Students);
- Sview << Students.Name << Students.Subject << Students.Mark;
-
- dbView Tview(Temperatures);
- Tview << Temperatures.Day << Temperatures.Time << Temperatures.Temp;
-
- // OK - Let's get Powerplant to work
- // Register the functions to create our custom Pane classes
- ColumnGraphWindow::RegisterClass();
-
- // Do the Stuff !
- mCWindow = new ColumnGraphWindow(this, &Sview, "\pStudent Grade Average", 100);
- mBWindow = new BarGraphWindow(this, &Tview, "\pDaily Temperatures");
- // mSBWindow = new StackedBarGraphWindow(this, &Tview, "\pDaily Temperatures");
- mSBWindow2 = new StackedBarGraphWindow(this, &Sview, "\pStudent Grade Average");
-
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~GraphTest
- // ---------------------------------------------------------------------------
- // Destructor
-
- GraphTestApp::~GraphTestApp()
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand
- // ---------------------------------------------------------------------------
- // Respond to commands
-
- Boolean
- GraphTestApp::ObeyCommand(
- CommandT inCommand,
- void *ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
- // Remember to add same cases to FindCommandStatus below
- // to enable/disable the menu items for the commands
-
- case cmd_PageSetup:
- DoPageSetup();
- break;
-
- case cmd_Print:
- PrintAll();
- break;
-
- default:
- cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus
- // ---------------------------------------------------------------------------
- // Pass back status of a (menu) command
-
- void
- GraphTestApp::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle.
- //
- // Set outEnabled to TRUE for commands that can be executed at
- // this time.
- //
- // If the associated menu items can have check marks, set
- // outUsesMark and outMark accordingly.
- //
- // Set outName to change the name of the menu item
-
- case cmd_Print:
- case cmd_PageSetup:
- outEnabled = true;
- break;
-
- default:
- LApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
- outMark, outName);
- break;
- }
- }
-
-
- // ---------------------------------------------------------------------------
- // • PrintAll
- // ---------------------------------------------------------------------------
- void
- GraphTestApp::PrintAll()
- {
- mCWindow->DoPrinting();
- mBWindow->DoPrinting();
- mSBWindow2->DoPrinting();
- }
-
-
- // ---------------------------------------------------------------------------
- // • DoPageSetup
- // ---------------------------------------------------------------------------
- // copied from LDocApplication
- void
- GraphTestApp::DoPageSetup()
- {
- UDesktop::Deactivate();
- UPrintingMgr::AskPageSetup(UPrintingMgr::GetDefaultPrintRecord());
- UDesktop::Activate();
- }